<template>
	<view :class="[primarySize()]">
		<view class="container">
			<view class="plr30 pt20 pb30">
				<view class="item" v-for="(item,index) in applyList" @click="bindResumeDetail(item.resume_id)">
					<view class="flex-box">
						<view class="flex-grow-1 col3 fs32 lh44">
							{{item.resume.personal.realname}}<text class="pl10 col9 fs26">| {{item.resume.personal.age}}岁</text>
						</view>
						<view class="fs24 col9">{{formatDatetime(item.createtime,'yyyy-mm-dd')}}</view>
					</view>
					<view class="mt15 fs24 col3 lh32">应聘岗位: {{item.job.job_name}}</view>
					<view class="fs24 col3 lh32 mt10">期望薪资:<text class="col8 fs28 lh32 fwb" v-if="item.resume.job_intention">{{item.resume.job_intention.length>0?item.resume.job_intention[0].expect_salary.name : ''}}/月</text>
					</view>
					<view class="clearfix m-ellipsis pb25">
						<view class="label">{{item.resume.personal.education_level.name}}</view>
						<view class="label">{{item.resume.personal.work_experience?item.resume.personal.work_experience.name : ''}}</view>
					</view>
					<view class="mt30 pt20 bt flex-box fs24 col3 pb30" v-if="item.resume.job_intention">
						<image src="@/static/public/icon45.png" mode="widthFix" class="ico30"></image>
						<view class="flex-grow-1 plr5">求职意向: {{item.resume.job_intention.length>0?item.resume.job_intention[0].fav_category.category_name : ''}}</view>
						<image src="@/static/public/icon_address2.png" mode="widthFix" class="ico24"></image>
						<view class="pl5">意向区域:{{item.resume.job_intention.length>0?item.resume.job_intention[0].fav_city.name : ''}}</view>
					</view>
					<view class="bt flex-box tc col3" v-if="item.status==0">
						<!-- <view class="flex-grow-1 h104">下载简历</view> -->
						<view class="flex-grow-1 h104" @click.stop="bindRejectApply(index)">不合适</view>
						<view class="flex-grow-1 h104 col8" @click.stop="bindAcceptApply(index)">面试邀请</view>
					</view>
					<image :src="iconPath('status_img0.png')" v-if="item.status==2" mode="widthFix" class="img"></image>
					<image src="@/static/public/status_img9.png" v-if="item.status==1" mode="widthFix" class="img"></image>
				</view>
				<view class="nothing" v-if="applyListMore.nothing">
					<image src="/static/public/icon_nothing.png" mode="aspectFit"></image>
					<text>暂无相关信息</text>
				</view>
				<view class="g-btn3-wrap" v-else>
					<view class="g-btn3" @click="fetchApplyList()">{{applyListMore.text}}</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	const app = getApp();
	export default {
		data() {
			return {
				
				applyList: [],
				applyListMore: {page:1},
			}
		},
		onReady() {
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: this.primaryColor()
			})
		},
		onLoad() {
			
			this.fetchApplyList();
		},
		onReachBottom() {
			this.fetchApplyList();
		},
		methods: {
			fetchApplyList() {
			    this.$util.fetch(this,'xilujob.job_apply/company_list',{},'applyListMore','applyList','data');
			},
			bindResumeDetail(id){
				uni.navigateTo({
					url: "/pages/company/talent_details?id="+id
				})
			},
			bindRejectApply(index) {
				let page = this;
				let apply = this.applyList[index];
			    uni.showModal({
			      title: '提示',
			      content: '确认标记为 不合适 ？',
			      success: res=>{
			        if (res.confirm) {
			          page.$core.post({url:'xilujob.job_apply/reject/id/'+apply.id,success:ret => {
			            page.applyList[index].status = ret.data.job_apply.status;
						page.$forceUpdate();
			            uni.$emit(app.globalData.Events.RefreshUserCenter);
			          }});
			        }
			      }
			    });
			},
			bindAcceptApply(index) {
			    let apply = this.applyList[index];
			    this.$core.post({url:'xilujob.resume/get_interview',data:{resume_id:apply.resume_id,user_id:apply.user_id},success:ret=>{
			      //到面试邀请页面
			      uni.navigateTo({
			        url: '/pages/company/invite_interview',
			        events: {
			          'dataTransfer': data => {
			            this.applyList[index].status = 2;
			            uni.$emit(app.globalData.Events.RefreshUserCenter);
			          }
			        },
			        success: res => {
			          res.eventChannel.emit('dataTransfer', {resume:apply.resume, apply:apply});
			        }
			      });
			    },fail:ret=>{
			      if(ret.code==-1) {
			        uni.showModal({
			        	title: '提示',
						content: ret.msg,
						showCancel: false,
			        })
			        return false;
			      }
			    }});
			
			},

		}
	}
</script>

<style lang="scss" scoped>
	.item {
		width: 690rpx;
		padding: 25rpx 30rpx 0;
		background: #FFFFFF;
		border-radius: 18rpx;
		margin-bottom: 20rpx;
		position: relative;
		.label{
			display: inline-block;
			vertical-align: top;
			height: 38rpx;
			background: #F7F7F7;
			border-radius: 4rpx;
			line-height: 38rpx;
			text-align: center;
			font-size: 20rpx;
			color: #A5A5A5;
			padding: 0 14rpx;
			margin-top: 20rpx;
			margin-right: 18rpx;
		}
		.bt{border-top: 1px solid #eee;}
		.h104{
			line-height: 104rpx;
			font-size: 24rpx;
		}
		.img{
			width: 122rpx;
			height: 122rpx;
			position: absolute;
			top: 92rpx;
			right: 40rpx;
		}
	}
</style>